package org.tigris.subversion.svnant.commands;

import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import org.apache.tools.ant.Project;
import org.tigris.subversion.svnant.SvnAntUtilities;
import org.tigris.subversion.svnclientadapter.ISVNClientAdapter;
import org.tigris.subversion.svnclientadapter.SVNClientException;
import org.tigris.subversion.svnclientadapter.SVNRevision;
import org.tigris.subversion.svnclientadapter.SVNUrl;

public class Cat extends SvnCommand
{
  private static final String MSG_CANT_GET_CONTENT = "Can't get the content of %s";
  private SVNUrl url = null;
  private File destFile = null;
  private SVNRevision revision = SVNRevision.HEAD;

  public void execute()
  {
    if (this.destFile == null)
      this.destFile = new File(getProject().getBaseDir(), this.url.getLastPathSegment());
    InputStream localInputStream = null;
    FileOutputStream localFileOutputStream = null;
    try
    {
      localFileOutputStream = new FileOutputStream(this.destFile);
      localInputStream = getClient().getContent(this.url, this.revision);
      byte[] arrayOfByte = new byte[5000];
      for (int i = localInputStream.read(arrayOfByte); i != -1; i = localInputStream.read(arrayOfByte))
        localFileOutputStream.write(arrayOfByte, 0, i);
    }
    catch (IOException localIOException)
    {
      throw ex(localIOException, "Can't get the content of %s", new Object[] { this.url });
    }
    catch (SVNClientException localSVNClientException)
    {
      throw ex(localSVNClientException, "Can't get the content of %s", new Object[] { this.url });
    }
    finally
    {
      SvnAntUtilities.close(localFileOutputStream);
      SvnAntUtilities.close(localInputStream);
    }
  }

  protected void validateAttributes()
  {
    SvnAntUtilities.attrNotNull("url", this.url);
    if (this.destFile != null)
      SvnAntUtilities.attrCanWrite("destFile", this.destFile);
    SvnAntUtilities.attrNotNull("revision", this.revision);
  }

  public void setUrl(SVNUrl paramSVNUrl)
  {
    this.url = paramSVNUrl;
  }

  public void setDestFile(File paramFile)
  {
    this.destFile = paramFile;
  }

  public void setRevision(String paramString)
  {
    this.revision = getRevisionFrom(paramString);
  }
}

/* Location:           C:\Users\Administrator\Desktop\svnant.jar
 * Qualified Name:     org.tigris.subversion.svnant.commands.Cat
 * JD-Core Version:    0.6.0
 */